//
//  TickersViewController.m
//  UEAssistant
//
//  Created by mac on 2017/7/24.
//  Copyright © 2017年 youyixinxi. All rights reserved.
//

#import "TickersViewController.h"
#import "TickersHeader.h"
#import "TickerModel.h"
#import "PayCusView.h"
#import <Masonry.h>
#import <VTMagic.h>
@interface TickersViewController ()<UITableViewDataSource,UITableViewDelegate,FoldTickersSectionHeaderViewDelegate>{

    NSMutableArray                  *_headerDataSource;
    NSMutableArray                  *_cellDataSource;
    NSMutableArray                  *_prefixData;
    NSMutableArray                  *_paydOrNoPay;
}

@property (nonatomic, strong) UITableView       *tableView;
@property (nonatomic, strong) NSDictionary      *foldInfoDic;/**< 存储开关字典 */
@property (nonatomic, assign) NSInteger         lastSection;//记录上次选中的cell
@property (nonatomic, strong) UIView            *statisticsView;
@property (nonatomic, strong) UIImageView       *seletImage;
@property (nonatomic, strong) UIButton          *selectButton;
@property (nonatomic, strong) UILabel           *selectAllLabel;
@property (nonatomic, strong) UILabel           *allMoneyLabel;
@property (nonatomic, strong) UILabel           *allMoneylabelSub;
@property (nonatomic, strong) UIButton          *payButton;
@property (nonatomic, strong) UIView            *coverView;
@property (nonatomic, strong) PayCusView        *payView;
@property (nonatomic, strong) NSMutableArray    *orderIdsArr;
@property (nonatomic, strong) NSString          *orderIdString;
@property (nonatomic, assign) BOOL              hasOrderAtlestOne;
@property (nonatomic, strong) UIImageView       *view_data_nil;
@property (nonatomic, strong) UILabel           *text_data_nil;

@end

@implementation TickersViewController

- (void)dealloc{

    [[NSNotificationCenter defaultCenter]removeObserver:self name:@"hiddenCorView" object:nil];
    [[NSNotificationCenter defaultCenter]removeObserver:self name:@"refreshOrderListData" object:nil];

}
- (void)viewDidAppear:(BOOL)animated  {
    [super viewDidAppear:animated];
    self.magicController.navigationItem.rightBarButtonItem = nil;
//    self.magicController.navigationItem.leftBarButtonItem = nil;
}

-(void)loadView
{
    [super loadView];
    
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(hiddenCorView) name:@"hiddenCorView" object:nil];
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(getOrderListDataMethod) name:@"refreshOrderListData" object:nil];
    
    _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0 ,0 , self.view.frame.size.width, self.view.frame.size.height-103-50*Radio)style:UITableViewStyleGrouped];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.backgroundColor = RGB(247, 247, 247, 1);
    _tableView.separatorColor = [UIColor colorWithWhite:0.9 alpha:1];
    [self.view addSubview:_tableView];
    
    _statisticsView = [[UIView alloc]initWithFrame:CGRectMake(0, Screen_Height-172*Radio, Screen_Width, 50*Radio)];
    _statisticsView.backgroundColor = [UIColor whiteColor];
    _statisticsView.layer.shadowColor = [UIColor grayColor].CGColor;
    _statisticsView.layer.shadowOffset = CGSizeMake(0, -0.7);
    _statisticsView.layer.shadowOpacity = 0.2;
    _statisticsView.layer.shadowRadius = 1.0;
    [self.view addSubview:_statisticsView];


    _seletImage = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 20, 20)];
    _seletImage.backgroundColor = [UIColor clearColor];
    _seletImage.center = CGPointMake(25, 50*Radio/2);
    _seletImage.image = [UIImage imageNamed:@"选择"];
    [_statisticsView addSubview:_seletImage];
    
    _selectAllLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 30, 20)];
    _selectAllLabel.center = CGPointMake(60, 50*Radio/2);
    _selectAllLabel.backgroundColor = [UIColor clearColor];
    _selectAllLabel.font = [UIFont systemFontOfSize:FLEXIBLE(14)];
    _selectAllLabel.textColor = RGB(51, 51, 51, 1);
    _selectAllLabel.text = @"全选";
    [_statisticsView addSubview:_selectAllLabel];
    
    _selectButton = [UIButton buttonWithType:UIButtonTypeCustom];
    _selectButton.frame = CGRectMake(0, 0, 40, 40);
    _selectButton.center = CGPointMake(25, 50*Radio/2);
    _selectButton.backgroundColor = [UIColor colorWithWhite:1 alpha:0];
    [_selectButton addTarget:self action:@selector(selectAllBtCliced:) forControlEvents:UIControlEventTouchUpInside];
    [_statisticsView addSubview:_selectButton];

    _allMoneyLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 40, 20)];
    _allMoneyLabel.center = CGPointMake(self.view.center.x-50*Radio, 50*Radio/2);
    _allMoneyLabel.backgroundColor = [UIColor clearColor];
    _allMoneyLabel.font = [UIFont systemFontOfSize:FLEXIBLE(13)];
    _allMoneyLabel.textColor = RGB(124, 124, 124, 1);
    _allMoneyLabel.text = @"合计：";
    [_statisticsView addSubview:_allMoneyLabel];
    
    _allMoneylabelSub = [[UILabel alloc]initWithFrame:CGRectMake(_allMoneyLabel.frame.origin.x+_allMoneyLabel.frame.size.width, _allMoneyLabel.frame.origin.y, 100*Radio, 20)];
    _allMoneylabelSub.backgroundColor = [UIColor clearColor];
    _allMoneylabelSub.font = [UIFont systemFontOfSize:FLEXIBLE(15)];
    _allMoneylabelSub.textColor = RGB(51, 51, 51, 1);
    _allMoneylabelSub.attributedText = [self attributeStringWith:@"0.00"];
    [_statisticsView addSubview:_allMoneylabelSub];

    _payButton = [UIButton buttonWithType:UIButtonTypeCustom];
    _payButton.frame = CGRectMake(Screen_Width-100*Radio, 0, 100*Radio, 50*Radio);
    _payButton.backgroundColor = RGB(39, 181, 238, 1);
    [_payButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [_payButton setTitle:@"支付(0)" forState:UIControlStateNormal];
    [_payButton addTarget:self action:@selector(payMoneyCleiced) forControlEvents:UIControlEventTouchUpInside];
    [_statisticsView addSubview:_payButton];
    
    [self.view addSubview:self.coverView];
}

- (NSMutableAttributedString *)attributeStringWith:(NSString *)money {
    NSString *str = [NSString stringWithFormat:@"%@马刀", money];
    NSMutableAttributedString *ats = [[NSMutableAttributedString alloc] initWithString:str];
    NSRange range = [str rangeOfString:money];
    [ats setAttributes:@{NSForegroundColorAttributeName:RGB(232, 78, 81, 1),NSFontAttributeName:[UIFont systemFontOfSize:14]} range:range];
    return ats;
}

- (NSMutableAttributedString *)attributeStringWith:(NSString *)money string:(NSString *)string{
    NSString *str = [NSString stringWithFormat:@"%@%@", money,string];
    NSMutableAttributedString *ats = [[NSMutableAttributedString alloc] initWithString:str];
    NSRange range = [str rangeOfString:string];
    [ats setAttributes:@{NSForegroundColorAttributeName:RGB(232, 78, 81, 1),NSFontAttributeName:[UIFont systemFontOfSize:FLEXIBLE(15)]} range:range];
    return ats;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    _tableView.sectionHeaderHeight = UITableViewAutomaticDimension;
    _tableView.estimatedSectionHeaderHeight = 80;
    
    _foldInfoDic = [NSMutableDictionary dictionary];
    _headerDataSource = [NSMutableArray array];
    _cellDataSource = [NSMutableArray array];
    _prefixData = [NSMutableArray array];
    _orderIdsArr = [NSMutableArray array];
    _paydOrNoPay = [NSMutableArray  array];
    self.magicController.navigationItem.leftBarButtonItem = nil;
    self.magicController.navigationItem.rightBarButtonItem = nil;
    [LSProgressHUD showLoadingToView:self.parentViewController.view];
    NSDictionary *dic = @{@"projectId":shareData.product_Id,@"teamId":detailsModel.ownerId};
    [AvailableNetWorking postWithUrl:projectOrder_connector params:dic successHandler:^(id responseObject) {
        
        if ([responseObject[@"code"] integerValue] == 200) {
            
            _tableView.backgroundColor = [UIColor whiteColor];
            NSLog(@"订单列表 == %@",responseObject[@"result"]);
            [_headerDataSource removeAllObjects];
            
            if (kObjectIsEmpty(responseObject[@"result"][@"feeResult"])) {
                
                [LSProgressHUD hiddenLoading:self.parentViewController.view];
                [self.tableView addSubview:self.view_data_nil];
                [self.tableView addSubview:self.text_data_nil];
                
            }else{
                _prefixData = responseObject[@"result"][@"feeResult"][@"docList"];

                for (int i = 0; i < ((NSArray *)(responseObject[@"result"][@"feeResult"][@"docList"])).count; i++) {

                    NSDictionary *dic = responseObject[@"result"][@"feeResult"][@"docList"][i];
                    TickerModel *model = [[TickerModel alloc]initWithDictionary:dic];
                    [_headerDataSource addObject:model];
                }

                [self.tableView reloadData];
                [LSProgressHUD hiddenLoading:self.parentViewController.view];
            }
        }else{
            
            NSLog(@"订单列表获取失败");
        }
        
    } falureHandler:^(NSError *error) {
        
    }];

    
}

- (void)getOrderListDataMethod{
    
    NSDictionary *dic = @{@"projectId":shareData.product_Id,@"teamId":detailsModel.ownerId};
    [AvailableNetWorking postWithUrl:projectOrder_connector params:dic successHandler:^(id responseObject) {
        
        if ([responseObject[@"code"] integerValue] == 200) {
            
            NSLog(@"订单列表 == %@",responseObject[@"result"]);
            [_headerDataSource removeAllObjects];
            
            if (![responseObject[@"result"][@"feeResult"] isEqual:[NSNull null]]){
                
                _prefixData = responseObject[@"result"][@"feeResult"][@"docList"];
                
                for (int i = 0; i < ((NSArray *)(responseObject[@"result"][@"feeResult"][@"docList"])).count; i++) {
                    
                    NSDictionary *dic = responseObject[@"result"][@"feeResult"][@"docList"][i];
                    TickerModel *model = [[TickerModel alloc]initWithDictionary:dic];
                    [_headerDataSource addObject:model];
                }
                [self.tableView reloadData];
            }
            
        }else{
        
            NSLog(@"订单列表获取失败");
        }
        
    } falureHandler:^(NSError *error) {
        
    }];

}

#pragma mark -- UITableViewDataSource,UITableViewDelegate

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

    UITableViewCell *cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:nil];
    cell.backgroundColor = RGB(250, 250, 250, 1);
    cell.textLabel.textColor = RGB(51, 51, 51, 1);
    cell.detailTextLabel.textColor = RGB(51, 51, 51, 1);
    cell.textLabel.font = [UIFont systemFontOfSize:FLEXIBLE(15)];
    cell.detailTextLabel.font = [UIFont systemFontOfSize:FLEXIBLE(15)];
    cell.textLabel.text = _prefixData[indexPath.section][@"oderList"][indexPath.row][@"scaleList"][0][@"name"];
    NSString *moneyText = [NSString stringWithFormat:@"%@字 × %@马刀",_prefixData[indexPath.section][@"oderList"][indexPath.row][@"scaleList"][0][@"quantity"],_prefixData[indexPath.section][@"oderList"][indexPath.row][@"scaleList"][0][@"fee"]];
    cell.detailTextLabel.text = moneyText;
    
    //同有已付款和未付款
    [_paydOrNoPay removeAllObjects];
    [((NSArray *)_prefixData[indexPath.section][@"oderList"]) enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        [_paydOrNoPay addObject:obj[@"order_status"]];
    }];
    for (int i = 0; i < _paydOrNoPay.count-1; i++) {
        
        if (_paydOrNoPay[i] != _paydOrNoPay[i+1]) {
            if ([_prefixData[indexPath.section][@"oderList"][indexPath.row][@"order_status"] integerValue] == 0) {
                cell.detailTextLabel.attributedText = [self attributeStringWith:moneyText string:@"（未付款）"];
            }else{
                cell.detailTextLabel.attributedText = [self attributeStringWith:moneyText string:@"（已付款）"];
            }

        }
    }
    
    
    
    return cell;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    NSString *key = [NSString stringWithFormat:@"%d", (int)section];
    BOOL folded = [[_foldInfoDic objectForKey:key] boolValue];
    return folded ? ((NSArray *)_prefixData[section][@"oderList"]).count : 0;

}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return _headerDataSource.count;
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 55 + [self autoCalculateWidthOrHeight:MAXFLOAT width:Screen_Width-120 fontsize:16 content:((TickerModel *)_headerDataSource[section]).document_name];
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{

    return 0.001f;
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{

    TickersHeader *headerView = [[TickersHeader alloc] initWithReuseIdentifier:@"header"];
    [headerView setFoldSectionHeaderViewWithTitle:((TickerModel *)_headerDataSource[section]).document_name detail:((TickerModel *)_headerDataSource[section]).not_pai_fee section:section canFold:YES height:[self autoCalculateWidthOrHeight:MAXFLOAT width:Screen_Width-120 fontsize:16 content:((TickerModel *)_headerDataSource[section]).document_name]];
    
    //处理折叠协议
    headerView.delegate = self;
    headerView.typeImage.image = [UIImage imageNamed:[self stringReplaceString:_prefixData[section][@"ext"]]];
    NSString *key = [NSString stringWithFormat:@"%d", (int)section];
    BOOL folded = [[_foldInfoDic valueForKey:key] boolValue];
    headerView.fold = folded;
    
    //判断是否已付款
    if ([((TickerModel *)_headerDataSource[section]).not_pai_fee doubleValue] == 0) {
        
        [headerView.selectButton setEnabled:NO];
        [headerView.PaidLabel setHidden:NO];
        [headerView.seletImage setHidden:YES];
        
    }
    
    //处理选中订单
    if (((TickerModel *)_headerDataSource[section]).isSelected) {
        headerView.seletImage.image = [UIImage imageNamed:@"选中"];
        _lastSection = section;
    
    }else{
        headerView.seletImage.image = [UIImage imageNamed:@"选择"];
    }
    
    //支付栏状态改变
    __block float totelMoney = 0.00;
    __block int   index      = 0;
    [_headerDataSource enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        
        if (((TickerModel *)obj).isSelected) {
            totelMoney += [((TickerModel *)obj).not_pai_fee floatValue];
            index += 1;
        }
    }];
    
    _allMoneylabelSub.attributedText = [self attributeStringWith:[NSString stringWithFormat:@"%.2f",totelMoney]];
    [_payButton setTitle:[NSString stringWithFormat:@"支付(%d)",index] forState:UIControlStateNormal];
    detailsModel.needPay = [NSString stringWithFormat:@"%.2f",totelMoney];
    
    return headerView;

}

#pragma mark sectionHeader的展开和选中协议

- (void)foldHeaderInSection:(NSInteger)SectionHeader {
    
    NSString *key = [NSString stringWithFormat:@"%d",(int)SectionHeader];
    BOOL folded = [[_foldInfoDic objectForKey:key] boolValue];
    NSString *fold = folded ? @"0" : @"1";
    [_foldInfoDic setValue:fold forKey:key];
    [self.tableView reloadData];
    
}

- (void)selectTikkets:(UIButton *)sender section:(NSInteger)sectionHeader{
    
    if (((TickerModel *)_headerDataSource[sectionHeader]).isSelected == NO) {
        
        ((TickerModel *)_headerDataSource[sectionHeader]).isSelected = YES;
        
        //拼接orderId
        [_prefixData[sectionHeader][@"oderList"] enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            for (NSString *key in [obj allKeys]) {
                if ([key isEqualToString:@"order_pay_document_id"] && [obj[@"order_status"] integerValue] == 0) {
                    [_orderIdsArr addObject:obj[@"order_pay_document_id"]];
                }
            }
            
        }];
        _orderIdString = [_orderIdsArr componentsJoinedByString:@","];

    }
    else{
        ((TickerModel *)_headerDataSource[sectionHeader]).isSelected = NO;
        
        //拼接orderId
        [_prefixData[sectionHeader][@"oderList"] enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            
            for (NSString *key in [obj allKeys]) {
                if ([key isEqualToString:@"order_pay_document_id"] && [obj[@"order_status"] integerValue] == 0) {
                    [_orderIdsArr removeObject:obj[@"order_pay_document_id"]];
                    
                }
            }
            
        }];
        _orderIdString = [_orderIdsArr componentsJoinedByString:@","];
    }
    [self.tableView reloadData];
}

#pragma mark -- 全选
- (void)selectAllBtCliced:(UIButton *)sender{

    sender.selected = !sender.selected;
    if (sender.selected) {
        _seletImage.image = [UIImage imageNamed:@"选中"];
        [_headerDataSource enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            if ([((TickerModel *)obj).not_pai_fee doubleValue] != 0) {
                ((TickerModel *)obj).isSelected = YES;
            }
        }];
        //拼接orderId
        [_orderIdsArr removeAllObjects];
        [_prefixData enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            
            for (NSString *key in [obj allKeys]) {
                if ([key isEqualToString:@"oderList"]) {
                    [obj[@"oderList"] enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
                        
                        for (NSString *key in [obj allKeys]) {
                            if ([key isEqualToString:@"order_pay_document_id"] && [obj[@"order_status"] integerValue] == 0) {
                                [_orderIdsArr addObject:obj[@"order_pay_document_id"]];
                                
                            }
                        }
                        
                    }];

                    
                }
            }
            
        }];
        _orderIdString = [_orderIdsArr componentsJoinedByString:@","];


    }else{
        _seletImage.image = [UIImage imageNamed:@"选择"];
        [_headerDataSource enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            
            ((TickerModel *)obj).isSelected = NO;
        }];
        //拼接orderId
        [_orderIdsArr removeAllObjects];
        _orderIdString = @"";
    }
    [self.tableView reloadData];
}

#pragma mark -- 去支付
- (void)payMoneyCleiced{

    [_headerDataSource enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        
        if (((TickerModel *)obj).isSelected) {
            _hasOrderAtlestOne = YES;
        }
    }];

    if (_hasOrderAtlestOne) {
        [self traversePayUserId];
        detailsModel.orderId = _orderIdString;
        _payView = [[PayCusView alloc]initWithFrame:CGRectMake(0, Screen_Height, Screen_Width, 0)];
        [self.view addSubview:_payView];
        [UIView animateKeyframesWithDuration:0.3
                                       delay:0.0
                                     options:UIViewKeyframeAnimationOptionLayoutSubviews
                                  animations:^{
                                      
                                      _payView.frame = CGRectMake(0, Screen_Height - 370*Radio-98, Screen_Width, 370*Radio);
                                      self.coverView.frame = CGRectMake(0, 0, Screen_Width, Screen_Height-370*Radio-80);
                                  }
                                  completion:^(BOOL finished) {
                                      
                                  }];
    }
    
}

#pragma mark -- 判断当前paid_user_type的类型

- (void)traversePayUserId{
    
    [_prefixData enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
       
        if ([obj[@"oderList"][0][@"user_id"] integerValue] == [obj[@"oderList"][0][@"vm_id"] integerValue]) {
            detailsModel.pay_user_type = @"vm";
        }
        if ([obj[@"oderList"][0][@"user_id"] integerValue] == [obj[@"oderList"][0][@"ower_id"] integerValue]){
            detailsModel.pay_user_type = @"owner";
        }
    }];
}


- (NSString *)stringReplaceString:(NSString *)string{

    if ([string isEqualToString:@"dwg"] || [string isEqualToString:@"dxf"]) {
        
        return @"CAD";
    }
    else if ([string isEqualToString:@"doc"] || [string isEqualToString:@"docx"] || [string isEqualToString:@"rtf"]){
    
        return @"word";
    }
    else if ([string isEqualToString:@"xls"] || [string isEqualToString:@"xlsx"]){
        
        return @"Exel";
    }
    else if ([string isEqualToString:@"ppt"] || [string isEqualToString:@"pptx"]){
        
        return @"ppt";
    }
    else if ([string isEqualToString:@"vsdx"]){
        
        return @"vsdx";
    }
    else if ([string isEqualToString:@"sdlxliff"]){
        
        return @"sdlxliff";
    }
    else{
    
        return @"pdf";
    }
}


- (void)hiddenCorView{

    [UIView animateKeyframesWithDuration:0.3
                                   delay:0.0
                                 options:UIViewKeyframeAnimationOptionLayoutSubviews
                              animations:^{
                                  
                                  self.coverView.frame = CGRectMake(0, 0, Screen_Width, 0);
                                  _payView.frame = CGRectMake(0, Screen_Height, Screen_Width, 0);
                              }
                              completion:^(BOOL finished) {
                                  
                              }];

}

#pragma mark -- 计算宽窄的函数
-(float)autoCalculateWidthOrHeight:(float)height
                             width:(float)width
                          fontsize:(float)fontsize
                           content:(NSString*)content
{
    //计算出rect
    CGRect rect = [content boundingRectWithSize:CGSizeMake(width, height)
                                        options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading
                                     attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:fontsize]} context:nil];
    
    //判断计算的是宽还是高
    if (height == MAXFLOAT) {
        return rect.size.height;
    }
    else
        return rect.size.width;
}


#pragma mark -- getter
- (UIView *)coverView{
    
    if (!_coverView) {
        _coverView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, Screen_Width, 0)];
        _coverView.backgroundColor = RGB(0, 0, 0, 0.2);
    }
    return _coverView;
}

- (UIImageView *)view_data_nil{
    
    if (!_view_data_nil) {
        _view_data_nil = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 229, 180)];
        _view_data_nil.image = [UIImage imageNamed:@"任务"];
        _view_data_nil.center = CGPointMake(Screen_Width/2.0, (Screen_Height-144)/2);
    }
    return _view_data_nil;
}

- (UILabel *)text_data_nil{
    
    if (!_text_data_nil) {
        _text_data_nil = [[UILabel alloc]initWithFrame:CGRectMake(0, _view_data_nil.frame.origin.y+_view_data_nil.frame.size.height+20*Radio, Screen_Width, 30)];
        _text_data_nil.backgroundColor = [UIColor clearColor];
        _text_data_nil.text = @"暂时没有订单";
        _text_data_nil.font = [UIFont systemFontOfSize:FLEXIBLE(18)];
        _text_data_nil.textColor = [UIColor grayColor];
        _text_data_nil.textAlignment = NSTextAlignmentCenter;
    }
    return _text_data_nil;
}

@end
